/*
 * @Descripttion: 
 * @version: 
 * @Author: lily
 * @Date: 2021-03-30 11:12:50
 * @LastEditors: lily
 * @LastEditTime: 2021-03-30 11:51:17
 */
/*
 * @lc app=leetcode.cn id=20 lang=javascript
 *
 * [20] 有效的括号
 */

// @lc code=start
/**
 * @param {string} s
 * @return {boolean}
 */
var isValid = function (s) {
    let stack = []
    for (const curr of s) {
        switch (curr) {
            case '}':
                if (stack.pop() !== "{") return false;
                break;
            case ']':
                if (stack.pop() !== "[") return false;
                break;
            case ')':
                if (stack.pop() !== "(") return false;
                break;
            default:
                stack.push(curr)
                break;
        }
    }
    return !stack.length;
};
// @lc code=end
console.log(isValid("([)]"));
